#include <stdio.h>
#include <string.h>

int main(int argc,const char * argv[])
{
    FILE *fp;
    char s[10];
    int line=0;

    if(argc != 2)
    {
        fputs("input error,try again\n",stderr);
        fputs("usage:./a.out file\n",stderr);
    }
    if((fp = fopen(argv[1],"r"))== NULL)
    {
        perror("fopen error");
        return -1;
    }

    while(fgets(s,sizeof(s),fp)!=NULL)
    {
        if(strlen(s)==sizeof(s)-1)
        {
            if(s[sizeof(s)-2]!='\n')
            {
                continue;
            }
        }
        line++;
    }

    printf("line = %d\n",line);
   
    fclose(fp);

    return 0;
}